package cn.wolfcode.producer_test.api._03_produce_mode;

import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

public class Producer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer("wolfcode-producer");
        //绑定namesrv地址
        defaultMQProducer.setNamesrvAddr("127.0.0.1:9876");
        //开启生产者
        defaultMQProducer.start();
        //创建一个消息
        Message message = new Message("03-consumer-mode", "Cluster".getBytes());

        //生产者发送消息
        defaultMQProducer.send(message);
        //关闭资源
        defaultMQProducer.shutdown();
    }
}
